{% extends 'dms_console.html' %}


{% block maincontent %}
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header layuiadmin-card-header-auto">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">日志类型</label>
                            <div class="layui-input-inline" style="width: 170px;">
                                <select name="business_type" id="business_type" lay-search>
                                    <option value="">直接选择或搜索选择</option>
                                    <option value="国际化">国际化</option>
                                    <option value="Lookup Classify">Lookup Classify</option>
                                    <option value="Lookup Item">Lookup Item</option>
                                    <option value="Lookup手工删除">Lookup手工删除</option>
                                    <option value="Lookup手工失效">Lookup手工失效</option>
                                    <option value="菜单">菜单</option>
                                    <option value="菜单修改">菜单修改</option>
                                    <option value="菜单删除">菜单删除</option>
                                    <option value="权限集">权限集</option>
                                    <option value="权限集权限点">权限集权限点</option>
                                    <option value="权限集菜单">权限集菜单</option>
                                    <option value="权限集维度">权限集维度</option>
                                    <option value="角色">角色</option>
                                    <option value="角色权限集">角色权限集</option>
                                    <option value="取消角色权限集">取消角色权限集</option>
                                    <option value="字典-计划">字典-计划</option>
                                    <option value="字典-指令">字典-指令</option>
                                    <option value="字典-公共">字典-公共</option>
                                    <option value="字典-监控">字典-监控</option>
                                    <option value="字典-eod">字典-eod</option>
                                    <option value="字典-接入层">字典-接入层</option>
                                    <option value="字典-mon his">字典-mon his</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">操作</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <select id="log_type" name="log_type" lay-search>
                                    <option value="">直接或搜索选择</option>
                                    <option value="修改">修改</option>
                                    <option value="删除">删除</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 120px;">IP</label>
                            <div class="layui-input-inline" style="width: 120px;">
                                <input type="text" id="ip" name="ip" placeholder="IP"
                                       class="layui-input"
                                       lay-affix="clear">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">字段名</label>
                            <div class="layui-input-inline" style="width: 120px;">
                                <input type="text" id="field_name" name="field_name" placeholder="字段名"
                                       class="layui-input"
                                       lay-affix="clear">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">原值</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" id="old_value" name="old_value" placeholder="原值"
                                       class="layui-input"
                                       lay-affix="clear">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">新值</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" id="new_value" name="new_value" placeholder="新值"
                                       class="layui-input"
                                       lay-affix="clear">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-list" lay-submit
                                    lay-filter="formSearch"
                                    id="btnSearch">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                            </button>
                            <button class="layui-btn layuiadmin-btn-list layui-btn-primary" type="reset"
                                    id="customReset">
                                <i class="layui-icon layui-icon-set-sm layuiadmin-button-btn"></i>重置
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-card-body">
                <table id="logTableId" lay-filter="logTableLayFilter"></table>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script>
        layui.use(['table', 'layer', 'form'], function () {
            var $ = layui.$;
            var table = layui.table;
            var layer = layui.layer;
            var form = layui.form;

            // 初始化表格 - 国际化
            var logTableIns = table.render({
                    elem: '#logTableId',
                    url: '/dms/api/log',
                    method: 'get',
                    page: true,
                    css: [ // 设置单元格样式
                        // 取消默认的溢出隐藏，并设置适当高度
                        '.layui-table-cell{height: 50px; line-height: 40px;}',
                        '.layui-table-cell .layui-colorpicker{width: 38px; height: 38px;}',
                        '.layui-table-cell select{height: 36px; padding: 0 5px;}'
                    ].join(''),
                    height: 650,
                    cols: [[
                        {field: 'log_id', title: 'ID', width: 80, align: 'center', fixed: 'left'},
                        {field: 'business_type', title: '日志类型', width: 150, align: 'left', fixed: 'left'},
                        {field: 'log_type', title: '操作', width: 80, align: 'center', fixed: 'left'},
                        {field: 'ip', title: 'IP', width: 150, align: 'center', fixed: 'left'},
                        {field: 'field_name', title: '字段名', width: 150, align: 'center'},
                        {field: 'old_value', title: '原值', width: 170, edit: 'textarea', align: 'left'},
                        {field: 'new_value', title: '新值', width: 170, align: 'left'},
                        {field: 'creation_date', title: '操作时间', width: 170, align: 'center'}
                    ]]
                })
            ;

            // 绑定表单提交事件。点击搜索按钮，提交表单
            form.on('submit(formSearch)', function (data) {
                logTableIns.reload({
                    where: data.field,
                    page: {curr: 1}
                });
                return false;
            });
        });
    </script>
{% endblock %}

